﻿using System;
using System.Linq;

namespace DNT.RavenQA.Core.Extensions
{
    public static class QueryableExtensions
    {
        public static IQueryable<T> PagedAs<T>(this IQueryable<T> query, Int32 currentPageIndex, Int32 pageSize, Int32 defaultPageIndex = 0)
        {
            return query.Skip((currentPageIndex - defaultPageIndex) * pageSize).Take(pageSize);
        }
    }
}